program summa;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  n, min, max, i, summ : integer;
  mass1 : array of integer;
  input : textfile;

begin
  assignfile(input, 'input.txt');
  reset(input);
  read(input, n);
  setlength(mass1, n);
  for i:=0 to n-1 do
    read(input, mass1[i]);
  max:=mass1[0];
    for i:=0 to n-1 do
      if (mass1[i]>max) then max:=mass1[i];
  min:=mass1[0];
    for i:=0 to n-1 do
      if (mass1[i]<min) then min:=mass1[i];
  summ:=max+min;
  write(summ);
  readln;






end.
